/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sample.test.cc.testfile;

import BESA.SystemLevel.transactions.agent.Intention;

/**
 *
 * @author Andrea
 */
public class EventInfo {

    public String aliasAgResource;
    public Intention intention;
    public Integer newValue;
    public Long idTransaction;

    public EventInfo() {
    }

    // idTransaccion aliasAgRecurso evType intention newValue
    public void setEvent(Long idTransaccion, String recurso, String intention, Integer... value) {
        this.idTransaction = idTransaccion;
        if (value.length!=0) {
            newValue = value[0];
        }
        aliasAgResource = recurso;

        if (intention.equals("READ")) {
            this.intention = Intention.READ;
        } else if (intention.equals("WRITE")) {
            this.intention = Intention.WRITE;
        }
    }

    public String getAliasAgRecurso() {
        return aliasAgResource;
    }


    public long getIdTransaccion() {
        return idTransaction;
    }

    public Intention getIntention() {
        return intention;
    }

    public long getNewValue() {
        return newValue;
    }

    public boolean isWrite() {
        return (newValue != null);
    }

    @Override
    // idTransaccion aliasAgRecurso evType intention newValue
    public String toString() {
        String ev = "[ "
                + this.idTransaction
                + " , "
                + this.aliasAgResource
                + " , ";
        if (isWrite()) {
            ev += "WRITE"
                    + " , "
                    + this.newValue;

        } else {
            ev += "READ";
        }

        ev += " ]";
        return ev;
    }
}
